package com.qf.team2.netdisc.dao;

import com.qf.team2.netdisc.common.pojo.qo.LinksDetails;
import com.qf.team2.netdisc.common.util.ComputationTimeUtils;
import com.qf.team2.netdisc.service.ShareService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath:spring-druid.xml","classpath:spring-mybatis.xml","classpath:spring-context.xml"})
public class test {
    @Autowired
    private ShareService shareService;
    @Test
    public void testSelectLinksDetails(){
        List<LinksDetails> linksDetails = shareService.selectLinksDetails(1);
        List<LinksDetails> list=new ArrayList();
        for (LinksDetails ld:linksDetails){
            if (ld.getDeadline()!=0){
                long result = ComputationTimeUtils.computationTime(ld.getCreateTime());
                long deadline = ld.getDeadline();
                long day=(deadline-result)/86400000;
                System.out.println(day);
                ld.setDeadline(day);
                list.add(ld);
            }
        }
        System.out.println(list);
    }
}
